package utils

import (
	"data-transfer/global"
	"go.uber.org/zap"
	"time"
)

// GetNowTimeStr 取得当前时间的字符串
func GetNowTimeStr() string {
	pattern := "2006-01-02 15:04:05"
	return time.Now().Format(pattern)

}

// DateParse 字符串日期转换为Time
func DateParse(date string) time.Time {
	layout := "20060102"
	tm, err := time.Parse(layout, date)
	if err != nil {
		global.LOG.Error("时间转换失败,取当前时间", zap.Any("error", err))
		return time.Now()
	}

	return tm
}
